/**
 * Copyright 厦门中软海晟信息技术有限公司 版权所有 违者必究 2019
 */
package com.vijos;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author : sunzb(sunzb@hsit.com.cn)
 * @date: 2019/4/19
 */
//连续数之和
//    有n个正整数排成一行
//从中取出一个或连续的若干个数，使它们的和能够被k整除
//改成：从中取出一个或若干个数，使它们的和能够被k整除
//    ?_?
public class P7_2_1090 {

    /*public static int test(int k, int[] in) {
        dataVerify(in);
        int count = 0;
        int index = 0;
        int sum = 0;
        while (index != in.length - 1) {
            for (int i = index; i < in.length - 1; i++) {
                for (int j = index; j <= i; j++) {
                    sum += in[j];
                }
                if (sum % k == 0) {
                    count++;
                }
                sum = 0;
            }
            index++;
        }
        return count;
    }*/
    public static List<List<Integer>> res = new ArrayList<List<Integer>>();

    public static int[] test(int k, int[] in) {
        go(k, 0, in, new ArrayList<>(), 0);
        return null;
    }

    private static void go(int k, int sum, int[] in, ArrayList<Integer> list, int index) {
        if (sum != 0 && sum % k == 0) {
            res.add(new ArrayList<>(list));
        }
        for (int i = index; i < in.length; i++) {
            list.add(in[i]);
            sum += in[i];
            go(k, sum, in, list, i + 1);
            list.remove(list.size() - 1);
        }
    }

    private static void dataVerify(int[] in) {

    }

    public static void main(String[] args) {
        System.out.println(test(3, new int[] {1,2,6,3,7,4}));
    }
}
